package com.chengxiaoxiao.ai_demo.api;

import com.chengxiaoxiao.ai_demo.entity.ConversationInfo;
import com.chengxiaoxiao.ai_demo.entity.OriginalMessage;
import com.chengxiaoxiao.ai_demo.vo.PageResult;
import com.chengxiaoxiao.ai_demo.vo.Result;
import com.chengxiaoxiao.ai_demo.vo.form.ChatForm;
import com.chengxiaoxiao.ai_demo.vo.query.ConversationInfoQuery;
import com.chengxiaoxiao.ai_demo.vo.vo.ChatResponseVo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.PathVariable;
import reactor.core.publisher.Flux;

import java.util.List;

/**
 * 聊天会话相关接口API
 *
 * @Description:
 * @Author Cheng Xiaoxiao
 * @Date: 2025-3-13 09:04:33
 */
@Tag(name = "聊天会话模块")
public interface ConversationInfoControllerApi {
    /**
     * 按照条件查询会话信息
     *
     * @param conversationInfoQuery 查询条件
     * @return 条件结果信息
     */
    @Operation(summary = "按照条件查询会话")
    Result<List<ConversationInfo>> list(@Parameter(description = "查询条件") ConversationInfoQuery conversationInfoQuery);

    /**
     * 分页及条件查询会话信息
     *
     * @param page                  页码
     * @param size                  分页大小
     * @param conversationInfoQuery 查询条件
     * @return 分页结果信息
     */
    @Operation(summary = "分页查询会话")
    Result<PageResult<ConversationInfo>> list(@Parameter(description = "分页大小") @PathVariable("size") Long size,
                                              @Parameter(description = "当前页") @PathVariable("page") Long page,
                                              @Parameter(description = "查询条件") ConversationInfoQuery conversationInfoQuery);

    /**
     * 创建新的会话
     *
     * @return 会话信息
     */
    @Operation(summary = "创建新的会话")
    Result<ConversationInfo> create();

    /**
     * 编辑会话
     */
    @Operation(summary = "编辑会话")
    Result<ConversationInfo> edit(@Parameter(description = "会话ID") String id, ConversationInfo conversationInfo);

    /**
     * 删除会话
     */
    @Operation(summary = "删除会话")
    Result<Boolean> delete(@Parameter(description = "会话ID") String id);

    /**
     * 进行聊天
     *
     * @param id       会话ID
     * @param chatForm 会话表单
     * @return 回答结果
     */
    @Operation(summary = "聊天-流式接口")
    Flux<ChatResponseVo> chatStream(@Parameter(description = "会话ID") String id, ChatForm chatForm);

    /**
     * 根据会话ID查询历史记录
     *
     * @param id 会话ID
     * @return 聊天历史记录
     */
    @Operation(summary = "根据会话ID查询历史记录")
    Result<List<OriginalMessage>> listConversationMessage(@Parameter(description = "会话ID") String id);
}
